#ifndef GAME_H
#define GAME_H

#include "Singleton.h"

#include <QDebug>
#include <QList>


class Glyph {
  public:
    virtual ~Glyph(){}
    virtual void Draw()
    {
        qInfo()<<__FUNCTION__;
    }
    virtual void SetFont(){}
};

class Character: public Glyph {
  public:
    Character(char c)
    {
        _charcode = c;
    }
    virtual ~Character(){}
    virtual void Draw()
    {
        qInfo()<<__FUNCTION__ << _charcode;
    }
private:
    char _charcode;
};

class Row: public Glyph {
  public:
    virtual ~Row(){}
    virtual void Draw()
    {
        qInfo()<<__FUNCTION__;
    }
};

class Column: public Glyph {
  public:
    virtual ~Column(){}
    virtual void Draw()
    {
        qInfo()<<__FUNCTION__;
    }
};

class Font {
  public:
    Font(QString f){}
};

// 外部存储
class GlyphContext {
public:
    GlyphContext(){}
    virtual ~GlyphContext(){}

    virtual void SetFont(Font*, int span=1){}   // 存储某一位置的字体信息
};

const int NCHARCODES = 128;
class GlyphFactory {
public:
    GlyphFactory(){
        for(int i=0; i< NCHARCODES; ++i)
        {
            _character[i] = 0;
        }
    }
    virtual ~GlyphFactory(){}
    virtual Character* CreateCharater(char c)
    {
        qInfo()<<__FUNCTION__;
        if(!_character[c])
        {
            _character[c] = new Character(c);
        }
        return _character[c];
    }
    virtual Row* CreateRow(){
        return new Row;
    }
    virtual Column* CreateColumn(){
        return new Column;
    }
private:
    Character* _character[NCHARCODES];  // 内部状态
};



#endif // GAME_H
